﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using DevComponents.DotNetBar;
using DuAnNH.Fd_class;

namespace DuAnNH
{
    public partial class Frm_Main : Office2007RibbonForm
    {
        //public Frm_Main()
        //{
        //    InitializeComponent();
        //}
        DataTable chucnang;
        string user = "";
        string pass = "";
        public Frm_Main(DataTable tb_Quyen, string UserName, string PassWord)
        {
            chucnang = tb_Quyen;
            user = UserName;
            pass = PassWord;

            InitializeComponent();
        }
        private void btt_MA_Click(object sender, EventArgs e)
        {
            Frm_MA frm_ma = new Frm_MA();
            frm_ma.ShowDialog();
        }

        private void btt_Ma_up_Click(object sender, EventArgs e)
        {
            Frm_MA_Update frm_ma_up = new Frm_MA_Update();
            frm_ma_up.ShowDialog();
        }

        private void btt_GB_Click(object sender, EventArgs e)
        {
            Frm_GhepBan frm_GB = new Frm_GhepBan();
            frm_GB.ShowDialog();
        }

        private void btt_TT_Click(object sender, EventArgs e)
        {
            Frm_TT frm_tt = new Frm_TT();
            frm_tt.ShowDialog();
        }

        private void btt_NV_Click(object sender, EventArgs e)
        {
            Frm_QL_NV frm_ql_nv = new Frm_QL_NV();
            frm_ql_nv.ShowDialog();
        }

        private void btt_TD_Click(object sender, EventArgs e)
        {
            Frm_QL_TD frm_ql_td = new Frm_QL_TD();
            frm_ql_td.ShowDialog();
        }

        private void btt_HD_Click(object sender, EventArgs e)
        {
            Frm_QL_HD frm_ql_hd = new Frm_QL_HD();
            frm_ql_hd.ShowDialog();
        }

        private void btt_TK_Click(object sender, EventArgs e)
        {
            Frm_TKe frm_tk = new Frm_TKe();
            frm_tk.ShowDialog();
        }


        private void Frm_Main_FormClosing(object sender, FormClosingEventArgs e)
        {
            e.Cancel = (MessageBox.Show("Bạn thật sự muốn đóng chương trình?", "Thông Báo!", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No);
        }

        private void Frm_Main_FormClosed(object sender, FormClosedEventArgs e)
        {
            Application.Exit();
        }

        private void btnThoat_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            labelItem2.Text = DateTime.Now.ToString();
            // chạy chữ
            int i, k, l, m, n, q;
            i = labelX44.Location.X;
            k = lbTenDN.Location.X;
            l = lb.Location.X;
            m = lbHoTen.Location.X;
            n = labelX72.Location.X;
            q = lbQuyen.Location.X;

            if (i >= 950)
                i = 100;
            else
                i = labelX44.Location.X + 5;
            if (k >= 950)
                k = 10;
            else
                k = lbTenDN.Location.X + 5;
            if (l >= 950)
                l = 100;
            else
                l = lb.Location.X + 5;
            if (m >= 950)
                m = 100;
            else
                m = lbHoTen.Location.X + 5;
            if (n >= 950)
                n = 100;
            else
                n = labelX72.Location.X + 5;
            if (q >= 950)
                q = 100;
            else
                q = lbQuyen.Location.X + 5;
            labelX44.Location = new Point(i, 5);
            lbTenDN.Location = new Point(k, 5);
            lb.Location = new Point(l, 5);
            lbHoTen.Location = new Point(m, 5);
            labelX72.Location = new Point(n, 5);
            lbQuyen.Location = new Point(q, 5);
        }

        private void notifyIcon1_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            Show();
            WindowState = FormWindowState.Maximized;
        }

        private void exitToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Close();
        }

        private void showToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Show();
            WindowState = FormWindowState.Maximized;
        }

        private void Frm_Main_Load(object sender, EventArgs e)
        {

        //    Load_CN();
        }


        public void Load_CN()
        {
            if (chucnang.Rows.Count > 0)
            {
                for (int i = 0; i < chucnang.Rows.Count; i++)
                {
                    switch (chucnang.Rows[i][0].ToString())
                    {
                        case "1":
                            {
                                btt_MA.Enabled = true;
                                break;
                            }
                        case "2":
                            {
                                btt_Ma_up.Enabled = true;
                                break;
                            }
                        case "3":
                            {
                                btt_GB.Enabled = true;
                                break;
                            }
                        case "4":
                            {
                                btt_TT.Enabled = true;
                                break;
                            }
                        case "5":
                            {
                                btt_NV.Enabled = true;
                                break;
                            }
                        case "6":
                            {
                                btt_TD.Enabled = true;
                                break;
                            }
                        case "7":
                            {
                                btt_HD.Enabled = true;
                                break;
                            }
                        case "8":
                            {
                                btt_TK.Enabled = true;
                                break;
                            }
                        case "9":
                            {
                                Btn_CauHinh.Visible = true;
                                break;
                            }
                        case "10":
                            {
                                Btn_PQ.Enabled = true;
                                break;
                            }
                        //case "11":
                        //    {
                        //        btnBCSDThuoc.Enabled = true;
                        //        break;
                        //    }

                    }
                }
            }
        }

        private void btnDangXuat_Click(object sender, EventArgs e)
        {
            Application.Restart();
            
        }

        //private void Btn_HuyBan_Click(object sender, EventArgs e)
        //{
        //    Frm_GhepBan_Huy fhb = new Frm_GhepBan_Huy();
        //    fhb.ShowDialog();
        //}

        //private void Btn_ChuyenBan_Click(object sender, EventArgs e)
        //{
        // //   Frm_ChuyenBan fcb = new Frm_ChuyenBan();
        //   // fcb.ShowDialog();
        //}

        private void Btn_PQ1_Click(object sender, EventArgs e)
        {
              Frm_PhanQuyen fpq = new Frm_PhanQuyen();
              fpq.ShowDialog();
        }

        private void btt_ChuyenBan_Click(object sender, EventArgs e)
        {
            Frm_ChuyenBan fcb = new Frm_ChuyenBan();
            fcb.ShowDialog();
        }

        private void btt_huyban_Click(object sender, EventArgs e)
        {
            Frm_GhepBan_Huy fhb = new Frm_GhepBan_Huy();
            fhb.ShowDialog();
        }


    }
}
